home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / mui / bcc.lha / BCC / Examples / BCCopts / App_lsopts.bc next >
Encoding:
Text File  |  1997-06-22  |  1.7 KB  |  81 lines

  1. #include <proto/dos.h>
  2. #include "App.bh"
  3. #include <string.h>
  4.  
  5. #define mcmp( x ) strncmp( x, linebuf, strlen( x ) )
  6.  
  7. Method App::LoadOpts()
  8. {
  9.  BPTR fh;
  10.  char linebuf[200];
  11.  
  12.     if( !(fh = Open( "BCCOptions", MODE_OLDFILE )) )
  13.         fh = Open( "ENV:bcc/BCCOptions", MODE_OLDFILE );
  14.  
  15.     if( fh ) {
  16.  
  17.         while( FGets( fh, linebuf, 199 ) ) {
  18.  
  19.             if( !mcmp( "deftype" ) ) {
  20.                 if( !strncmp( "BOP", linebuf + 8, 3 ) )
  21.                     deftype->Active = 1;
  22.             }
  23.  
  24.             if( !mcmp( "verbose" ) ) verbose->Active = 1;
  25.             if( !mcmp( "noversion" ) ) noversion->Active = 1;
  26.             if( !mcmp( "forcetrans" ) ) forcetrans->Active = 1;
  27.  
  28.             if( !mcmp( "incdir" ) ) {
  29.                 if( linebuf[7] == '"' && linebuf[strlen(linebuf)-1] == '"' ) {
  30.                     linebuf[strlen(linebuf)-1] = 0;
  31.                     incdir->Contents = linebuf+8;
  32.                 }
  33.             }
  34.  
  35.             if( !mcmp( "tagbase" ) ) {
  36.                 tagbase->Contents = linebuf + 8;
  37.             }
  38.  
  39.  
  40.         }
  41.  
  42.         Close( fh );
  43.  
  44.     }
  45.  
  46. }
  47.  
  48. Method App::SaveName( char *name )
  49. {
  50.  
  51.  BPTR fh;
  52.  
  53.     if( !(fh = Open( name, MODE_NEWFILE )) ) {
  54.         Printf( "Error: can not save opts file\n" );
  55.         mreturn 0;
  56.     }
  57.         
  58.     if( deftype->Active ) FPrintf( fh, "deftype BOP\n" );
  59.     if( verbose->Active ) FPrintf( fh, "verbose\n" );
  60.     if( noversion->Active ) FPrintf( fh, "noversion\n" );
  61.     if( forcetrans->Active ) FPrintf( fh, "forcetrans\n" );
  62.     if( stricmp( (char*)incdir->Contents, "ENV:bcc/" ) && stricmp( (char*)incdir->Contents, "ENV:bcc" ) ) 
  63.         FPrintf( fh, "incdir \"%s\"\n", incdir->Contents );
  64.     if( strcmp( "none", (char*)tagbase->Contents ) ) 
  65.         FPrintf( fh, "tagbase %s\n", tagbase->Contents );
  66.  
  67.     Close( fh );
  68.  
  69. }
  70.  
  71. nodata Method App::SaveOpts( long default )
  72. {
  73.     if( default ) {
  74.         obj->SaveName( "ENV:bcc/BCCOptions" );
  75.         obj->SaveName( "ENVARC:bcc/BCCOptions" );
  76.     } else obj->SaveName( "BCCOptions" );
  77.  
  78.     obj->Application_ReturnID( MUIV_Application_ReturnID_Quit );
  79.  
  80. }
  81.